//
//  SplashView.m
//  HelloWorld
//
//  Created by jing zhao on 11/26/14.
//
//

#import "SplashView.h"

#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))

#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH >= 667.0)

@interface SplashView ()

//@property(strong,nonatomic)UIActivityIndicatorView *activity;

@end


@implementation SplashView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        //imageview
        
        UIImage *image;
        if (IS_IPHONE_4_OR_LESS) {
            image = [UIImage imageNamed:@"Default.png"];
            if (IS_RETINA) {
            image = [UIImage imageNamed:@"Default@2x.png"];
            }
        }else if (IS_IPHONE_5){
            image = [UIImage imageNamed:@"Default-568h@2x.png"];
        }else{
            image = [UIImage imageNamed:@"Default-667h@2x.png"];
        }
        
        UIImageView *imageview =[[UIImageView alloc]initWithImage:image];
        [self addSubview:imageview];
        imageview.frame =frame;
//        imageview.contentMode=UIViewContentModeScaleAspectFit;
        
//        imageview.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
        
        //activity
//        UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:  UIActivityIndicatorViewStyleWhiteLarge];
//        [self addSubview:activity];
//        self.activity = activity;
        
        // Initialization code
    }
    return self;
}

-(void)setViewFrame:(CGRect)frame
{
    self.frame=frame;
//    CGRect rectScreen = [[UIScreen mainScreen]bounds];
//    self.activity.center=CGPointMake(self.center.x,rectScreen.size.height*0.9) ;
}


-(void)show
{
    self.hidden = NO;
//    self.activity.hidden=NO;
//    [self.activity startAnimating];

}

-(void)hide
{
    self.hidden = YES;
//    self.activity.hidden = YES;
//    [self.activity stopAnimating];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
